def test():
    print('start')
    rec1 = yield 'a'
    print('rec1', rec1)

    rec2 = yield 'b'
    print('rec2', rec2)

    rec3 = yield 'c'
    print('rec3', rec3)

    yield 666
    print('已无返回值，程序结束')


if __name__ == '__main__':
    print('---')
    test = test()
    print('test', test)
    value1 = next(test)
    print('value1', value1)
    value2 = test.send('发送信息第一次')
    print('value2', value2)
    value3 = test.send('发送信息第二次')
    print('value3', value3)
    value4 = test.send('发送信息第三次')
    print('value4', value4)

    try:
        next(test)
    except Exception as e:
        print('迭代结束', e)

